#ifndef SET_SOK_H
#define SET_SOK_H
#include <sys/socket.h>
#include <sys/time.h>
int set_block_timout(int sockfd, int sec, int usec) {
	struct timeval timeout;
	timeout.tv_sec =sec;
	timeout.tv_usec=usec;
	if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)) < 0) {
		perror("setsockopt SO_RCVTIMEO failed");
		return -1;
	}
	if (setsockopt(sockfd, SOL_SOCKET,SO_SNDTIMEO, (char*)&timeout, sizeof(timeout)) < 0) {
		perror("setsockopt SO_SNDTIMEO failed");
		return -1; // if program returned here, it's also setted up there RCVTIMEO
	}

	return 0; // success
}
#endif
